package com.ecfront.test.dao;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.ecfront.dao.ShopDAO;
import com.ecfront.pojo.GoodsImpl;
import com.ecfront.pojo.Shop;
import com.ecfront.pojo.ShopGoodsSort;
import com.ecfront.pojo.ShopStyle;
import com.ecfront.pojo.User;

import junit.framework.TestCase;

public class testShop extends TestCase{
	private static final ShopDAO shopDao = (ShopDAO)SpringUtilTest.getBean("ShopDAO");
	//保存测试�������
	public void testSave(){
		Shop shop = new Shop();
		shop.setDomain("zhaoke.qaooo.com");
		shop.setInfo("赵科的私人商铺");
		shop.setIsLock(0);
		shop.setLogoUrl("logo.jpg");
		shop.setName("赵科");
		shop.setNote("赵科的公告");
		
//		User user = new User();
//		user.setId(1);
//		shop.setUsers(user);
		
		ShopStyle ss = new ShopStyle();
		ss.setId(1);
		shop.setStyle(ss);
		
		shopDao.save(shop);
	}
	//属性测试���Բ���
	public void testFindAll(){
		List list = shopDao.findAll();
		for(Iterator iter = list.iterator();iter.hasNext();){
			Shop shop = (Shop)iter.next();
			System.out.println(shop.getDomain());
			System.out.println(shop.getInfo());
			System.out.println(shop.getLogoUrl());
			System.out.println(shop.getName());
			
			User user = shop.getUsers();
			System.out.println(user.getName());
			
			ShopStyle ss = shop.getStyle();
			System.out.println(ss.getTitle());
		}
	}
	//删除测试
	public void testDel(){
		Shop shop = new Shop();
		shop.setId(2);
		
		shopDao.delete(shop);
	}
	//属性测试���Բ���
	public void testProperty1(){
		Shop shop = shopDao.findById(1);
		System.out.println(shop.getDomain());
		System.out.println(shop.getInfo());
		System.out.println(shop.getLogoUrl());
		System.out.println(shop.getName());
		
		User user = shop.getUsers();
		System.out.println(user.getName());
		
		ShopStyle ss = shop.getStyle();
		System.out.println(ss.getTitle());
		
		Set list = shop.getShopGoodsSorts();
		for(Iterator iter = list.iterator();iter.hasNext();){
			ShopGoodsSort sgs = (ShopGoodsSort)iter.next();
			System.out.println(sgs.getName());
		}
		Set set = shop.getGoodsImpl();
		for(Iterator iter = set.iterator();iter.hasNext();){
			GoodsImpl sgs = (GoodsImpl)iter.next();
			System.out.println(sgs.getInfo());
		}
	}
	public void testProperty2(){
		List list = shopDao.findBySname("赵科");
		for(Iterator iter = list.iterator();iter.hasNext();){
			Shop shop = (Shop)iter.next();
			System.out.println(shop.getDomain());
			System.out.println(shop.getInfo());
			System.out.println(shop.getLogoUrl());
			System.out.println(shop.getName());
			
			User user = shop.getUsers();
			System.out.println(user.getName());
			
			ShopStyle ss = shop.getStyle();
			System.out.println(ss.getTitle());
		}
	}
}
